<template>
  <common-info-dialog
    :visible.sync="dialogShow"
    @cancel="close"
    :button-loading="isPersistenceLoading"
  >
    <common-info-table>
      <common-info-table-cell label="字典类型编码">{{
        form.dictId
      }}</common-info-table-cell>
      <common-info-table-cell label="字典名称">{{
        form.dictName
      }}</common-info-table-cell>
      <common-info-table-cell label="字典类型">{{
        form.dictType
      }}</common-info-table-cell>
      <common-info-table-cell label="状态">{{
        form.status == 0 ? "正常" : "停用"
      }}</common-info-table-cell>
      <common-info-table-cell label="创建时间">{{
        form.createTime
      }}</common-info-table-cell>
      <common-info-table-cell label="创建者">{{
        form.createBy
      }}</common-info-table-cell>
      <common-info-table-cell label="备注">{{
        form.remark
      }}</common-info-table-cell>
    </common-info-table>
  </common-info-dialog>
</template>

<script>
import { dict_type_getDictDataInfo } from "@/api/management/configure/index.js";

export default {
  components: {},
  props: {},
  data() {
    return {
      isPersistenceLoading: false,
      dialogTitle: "详情", // 标题
      dialogShow: false, // 是否显示
      form: {},
    };
  },
  watch: {},
  computed: {},
  methods: {
    /**
     * 关闭
     */
    close() {
      this.dialogShow = false;
    },
    /**
     * 显示
     */
    show(dictId) {
      this.dialogShow = true;
      this.form = {};
      dict_type_getDictDataInfo({ dictId: dictId }).then((res) => {
        this.form = res.data;
      });
    },
    /**
     * 提交
     */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id) {
            if (!this.isPersistenceLoading) {
              this.isPersistenceLoading = true;
              dict_data_edit(this.form)
                .then((res) => {
                  if (res && res.code === 200) {
                    this.$GlobalSuccessMessage("操作成功");
                    this.close();
                  } else {
                    this.$GlobalErrorConfirm("编辑失败", res.msg);
                  }
                })
                .finally(() => {
                  this.isPersistenceLoading = false;
                });
            }
          }
        }
      });
    },
  },
  created() {},
  mounted() {},
};
</script>
<style lang="scss" scoped>
</style>
